package com.bfl.learning.controller;

import com.bfl.learning.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/freemarker")
public class FreeMarkerController {

    @RequestMapping("/jsp")
    public ModelAndView jsp(){
        User user = new User();
        user.setUsername("sg");
        user.setPassword("1234");
        List<User> users  = new ArrayList<>();
        users.add(user);

        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        mv.addObject("users",users);

        //language=JSON
        String json = "{\"name\": \"tome\", \"age\": 10}";


        return mv;
    }

}